﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace CourseTeaching.WebApi.DBModel;

public partial class CourseteachingContext : DbContext
{
    public CourseteachingContext()
    {
    }

    public CourseteachingContext(DbContextOptions<CourseteachingContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Comment> Comments { get; set; }

    public virtual DbSet<Login> Logins { get; set; }

    public virtual DbSet<User> Users { get; set; }

    public virtual DbSet<UserLike> UserLikes { get; set; }

    public virtual DbSet<Video> Videos { get; set; }

    public virtual DbSet<VideoCheckingRecord> VideoCheckingRecords { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseMySql("server=101.34.248.54;user id=root;password=whx1004;database=courseteaching", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.2.0-mysql"));

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_0900_ai_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<Comment>(entity =>
        {
            entity.HasKey(e => e.CommentId).HasName("PRIMARY");

            entity.ToTable("comment");

            entity.Property(e => e.CommentId)
                .HasComment("序号")
                .HasColumnName("comment_id");
            entity.Property(e => e.CheckingStatus)
                .HasMaxLength(10)
                .HasComment("审核状态")
                .HasColumnName("checking_status");
            entity.Property(e => e.CommentTime)
                .HasComment("评论发布时间")
                .HasColumnType("datetime")
                .HasColumnName("comment_time");
            entity.Property(e => e.ContentText)
                .HasMaxLength(100)
                .HasComment("发表内容")
                .HasColumnName("content_text");
            entity.Property(e => e.UserId)
                .HasComment("发表者序号")
                .HasColumnName("user_id");
            entity.Property(e => e.UserName)
                .HasMaxLength(255)
                .HasComment("用户昵称")
                .HasColumnName("user_name");
            entity.Property(e => e.VideoId)
                .HasComment("视频序号")
                .HasColumnName("video_id");
        });

        modelBuilder.Entity<Login>(entity =>
        {
            entity.HasKey(e => e.UserId).HasName("PRIMARY");

            entity.ToTable("login");

            entity.Property(e => e.UserId)
                .HasComment("序号")
                .HasColumnName("user_id");
            entity.Property(e => e.LoginTime)
                .HasComment("登录时间")
                .HasColumnType("datetime")
                .HasColumnName("login_time");
            entity.Property(e => e.UserName)
                .HasMaxLength(255)
                .HasComment("用户名")
                .HasColumnName("user_name");
        });

        modelBuilder.Entity<User>(entity =>
        {
            entity.HasKey(e => e.UserId).HasName("PRIMARY");

            entity.ToTable("user");

            entity.HasIndex(e => e.UserName, "userName");

            entity.Property(e => e.UserId)
                .HasComment("序号")
                .HasColumnName("user_id");
            entity.Property(e => e.CreateBy)
                .HasComment("创建人")
                .HasColumnName("create_by");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.Email)
                .HasMaxLength(50)
                .HasComment("邮箱")
                .HasColumnName("email");
            entity.Property(e => e.Gender)
                .HasMaxLength(1)
                .HasComment("性别")
                .HasColumnName("gender");
            entity.Property(e => e.Image)
                .HasMaxLength(1000)
                .HasComment("头像")
                .HasColumnName("image");
            entity.Property(e => e.Password)
                .HasMaxLength(255)
                .HasComment("密码")
                .HasColumnName("password");
            entity.Property(e => e.Salt)
                .HasMaxLength(255)
                .HasComment("盐")
                .HasColumnName("salt");
            entity.Property(e => e.UpdateBy)
                .HasComment("修改人")
                .HasColumnName("update_by");
            entity.Property(e => e.UpdateTime)
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("update_time");
            entity.Property(e => e.UserName)
                .HasMaxLength(10)
                .HasComment("昵称")
                .HasColumnName("user_name");
        });

        modelBuilder.Entity<UserLike>(entity =>
        {
            entity.HasKey(e => e.LikeId).HasName("PRIMARY");

            entity.ToTable("user_like");

            entity.Property(e => e.LikeId)
                .HasComment("点赞序号")
                .HasColumnName("like_id");
            entity.Property(e => e.LikeTime)
                .HasComment("点赞时间")
                .HasColumnType("datetime")
                .HasColumnName("like_time");
            entity.Property(e => e.UserId)
                .HasComment("用户序号")
                .HasColumnName("user_id");
            entity.Property(e => e.UserName)
                .HasMaxLength(255)
                .HasComment("用户昵称")
                .HasColumnName("user_name");
            entity.Property(e => e.VideoId)
                .HasComment("视频序号")
                .HasColumnName("video_id");
        });

        modelBuilder.Entity<Video>(entity =>
        {
            entity.HasKey(e => e.VideoId).HasName("PRIMARY");

            entity.ToTable("video");

            entity.Property(e => e.VideoId)
                .HasComment("视频序号")
                .HasColumnName("video_id");
            entity.Property(e => e.CreateBy)
                .HasComment("创建人")
                .HasColumnName("create_by");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.LikeNum)
                .HasComment("点赞数")
                .HasColumnName("like_num");
            entity.Property(e => e.UpdateBy)
                .HasComment("修改人")
                .HasColumnName("update_by");
            entity.Property(e => e.UpdateTime)
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("update_time");
            entity.Property(e => e.UserId)
                .HasComment("用户序号")
                .HasColumnName("user_id");
            entity.Property(e => e.UserName)
                .HasMaxLength(10)
                .HasComment("发布者昵称")
                .HasColumnName("user_name");
            entity.Property(e => e.VideoDate)
                .HasComment("发布时间")
                .HasColumnType("datetime")
                .HasColumnName("video_date");
            entity.Property(e => e.VideoMessage)
                .HasMaxLength(255)
                .HasComment("审核结果描述")
                .HasColumnName("video_message");
            entity.Property(e => e.VideoStatus)
                .HasMaxLength(10)
                .HasComment("审核情况")
                .HasColumnName("video_status");
            entity.Property(e => e.VideoTitle)
                .HasMaxLength(50)
                .HasComment("主题")
                .HasColumnName("video_title");
            entity.Property(e => e.VideoType)
                .HasMaxLength(255)
                .HasComment("类型")
                .HasColumnName("video_type");
            entity.Property(e => e.VidioIntroduction)
                .HasMaxLength(255)
                .HasComment("简介")
                .HasColumnName("vidio_introduction");
        });

        modelBuilder.Entity<VideoCheckingRecord>(entity =>
        {
            entity.HasKey(e => e.RecordId).HasName("PRIMARY");

            entity.ToTable("video_checking_record");

            entity.Property(e => e.RecordId)
                .HasComment("审核记录序号")
                .HasColumnName("record_id");
            entity.Property(e => e.AdminId)
                .HasComment("审核者序号")
                .HasColumnName("admin_id");
            entity.Property(e => e.AdminName)
                .HasMaxLength(255)
                .HasComment("审核者昵称")
                .HasColumnName("admin_name");
            entity.Property(e => e.RecordMessage)
                .HasMaxLength(255)
                .HasComment("审核结果描述")
                .HasColumnName("record_message");
            entity.Property(e => e.RecordStatus)
                .HasMaxLength(20)
                .HasComment("审核状态")
                .HasColumnName("record_status");
            entity.Property(e => e.RecordTime)
                .HasComment("审核时间")
                .HasColumnType("datetime")
                .HasColumnName("record_time");
            entity.Property(e => e.VideoId)
                .HasComment("视频序号")
                .HasColumnName("video_id");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
